#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
#include <functional>

//内建函数对象 关系仿函数
/*
bool equal_to<T>        等于
bool not_equal_to<T>    不等于
bool greater<T>         大于
bool greater_equal<T>   大于等于
bool less<T>            小于
bool less_equal<T>      小于等于
*/

//大于 greater
class MyCompare
{
public:
    bool operator()(int v1, int v2)
    {
        return v1 > v2;
    }
};

void test1()
{
    vector<int>v;

    v.push_back(10);
    v.push_back(40);
    v.push_back(30);
    v.push_back(20);

    for (vector<int>::iterator it = v.begin();it != v.end();it++)
    {
        cout << *it << " ";
    }
    cout << endl;

    // 降序
    // sort(v.begin(), v.end(), MyCompare());
    // greater<int>()    内建函数对象
    sort(v.begin(), v.end(), greater<int>());
    
    for (vector<int>::iterator it = v.begin();it != v.end();it++)
    {
        cout << *it << " ";
    }
    cout << endl;
}

int main()
{
    test1();
    return 0;
}